package com.hxk.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hxk.pojo.User;
import com.hxk.service.UserService;
/**
 * 登录拦截器测试，如果当用户没有登录，不能方法其他资源，登录后可以
 * @author Cactus
 */
@Controller
public class LoginController {
	@Resource
	private UserService userServiceImpl;
	
	@RequestMapping("login")
	public String login(User user, HttpSession session){
		User u = this.userServiceImpl.selectByUser(user);
		if(u != null){
			session.setAttribute("user", u);
		}else{
			return "login";
		}
		return "index";
	}
}
